package com.yfs.cloud.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
* @Company: 影法師工作室
* @Description: swagger2 的配置类 
* @author 影法師  
* @date 2020年8月27日 下午4:10:29 
* @version V1.0
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

	@Value("${spring.swagger2.enabled}")
	private Boolean swaggerEnabled;

	@Bean
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).enable(swaggerEnabled).select()
				.apis(RequestHandlerSelectors.basePackage("com.yfs.cloud.controller")).paths(PathSelectors.any())
				.build();
	}

	private ApiInfo apiInfo() {
		return new ApiInfoBuilder().title("哇塞swagger2文档").description("影法師的接口文档")
				.termsOfServiceUrl("http://yfscfs.gitee.io").version("1.0").build();
	}

}
